package com.hopu.oa.dao.UserManage;

import com.hopu.oa.entity.dto.user.manage.UserManage;
import com.hopu.oa.entity.user.AoaPosition;
import com.hopu.oa.entity.user.AoaUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
@Mapper
public interface UserManageDao {


    /*
     @Description : 根据当前用户  角色/部门  查询所用员工
     @Date   :  2021/11/15
     @Param  : [roleId, deptId]
     @return : java.util.List<com.hopu.oa.entity.dto.user.manage.UserManage>
    */
    List<UserManage> queryStaffByUserRoleOrDept
    (@Param("roleId") Integer roleId, @Param("deptId") Integer deptId, @Param("index") int index, @Param("size") int size, @Param("name") String name);


    /*
    @Description : 根据当前用户  角色/部门  查询条数
    @Date   :  2021/11/15
    @Param  : [roleId, deptId]
    @return : java.util.List<com.hopu.oa.entity.dto.user.manage.UserManage>
   */
    int queryStaffCount(@Param("roleId") Integer roleId, @Param("deptId") Integer deptId, @Param("name") String name);


    @Delete("delete from aoa_user where user_id = #{userId}")
    int userManage_deleteUserById(int userId);


    List<Map<String, String>> queryDeptIdAndDeptName(@Param("roleId") Integer roleId, @Param("deptId") Integer deptId);


    @Select("select   position_id,name  from aoa_position where deptid= #{id} ")
    List<AoaPosition> queryPositionIdAndPositionName(int deptId);

    List<Map<String, String>> queryRoleByUserId(Integer roleId);


    int insertUser(UserManage user);

    AoaUser queryUpdateUserById(String userid);


    int updateUserByUser(UserManage user);

    @Select("select * from aoa_user where dept_id = #{deptId} order by role_id limit 0,1")
    int queryFatherId(String deptId);
}
